#include <stdio.h> 
#include <stdlib.h> 
#include <sys/types.h> 
#include <unistd.h> 

/* ..............PAORGAM ...........
   ..................ARG_LIST .... NULL ...........
   ................ ID. */ 

int spawn (char* program, char** arg_list) 
{ 
  pid_t child_pid; 
  /* .......*/  
  child_pid = fork (); 
  if (child_pid != 0) 
    /* .......*/ 
    return child_pid; 
  else { 
    /* ............. PROGRAM.*/ 
    execvp (program, arg_list); 
    /* execvp ...............*/ 
    fprintf (stderr, "an error occurred in execvp\n"); 
    abort (); 
  } 
} 

int main () 
{ 
  /* ..... ls ....... */ 
  char* arg_list[] = { 
    "ls", /* argv[0], ..... */ 
    "-l", 
    "/", 
    NULL /* ....... NULL .... */ 
  }; 

  /* ......... ls .......... ID */ 
  spawn ("ls", arg_list); 

  printf ("done with main program\n"); 

  return 0; 
} 
